﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FacebookWrapper.ObjectModel;

namespace B13_Ex03_David_300512340_Alexey_321203689.Strategy
{
    /// <summary>
    /// Pattern: Strategy.
    /// Role: Mechanism.
    /// 1. Is configured with a ConcreteStrategy object.
    /// 2. Maintains a reference to a Strategy object.
    /// </summary>
    public class Searcher
    {
        private ISearchPost SearchPost { get; set; }

        public Searcher(ISearchPost i_SearchPost)
        {
            SearchPost = i_SearchPost;
        }

        public List<FeedWrapper> Search(ValuesToSearch i_Obj)
        {
            List<FeedWrapper> feedList = new List<FeedWrapper>();
            List<FeedWrapper> sortFeedList = new List<FeedWrapper>();

            feedList = i_Obj.User.GetFeedsList();
            foreach (Post feed in i_Obj.User.UserInformation.NewsFeed)
            {
                if (feed.Message != null)
                {
                    if (SearchPost.SearchByParametrs(feed, i_Obj))
                    {
                        sortFeedList.Add(new FeedWrapper() { Feed = feed });
                    }
                }
            }

            return sortFeedList;
        }
    }
}
